package me.lxqq.erp.bemall;

import com.huice.base.CheckPoint;
import com.huice.base.Log;
import com.huice.base.TestBase;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.util.Map;

import static org.testng.Assert.*;

/**
 * 登陆功能测试
 * 时间：2018年6月4日16:11:19
 * 作者:lxqq0000
 */
public class LoginTest extends TestBase {

    @Test
    public void testLogin() throws Exception {


        Object[][] dataArr = getdata();
        if (dataArr.length == 0 || dataArr[0].length == 0) {
            Assert.fail("数据配置文件没有数据！");
        }
        Map<String, String> dataMap = (Map<String, String>) dataArr[0][0];

        locator.linkTo(dataMap.get("登陆页URL"));
        locator.sendKeys("登陆", "账号", dataMap.get("账号"));
        locator.sendKeys("登陆", "密码", dataMap.get("密码"));
        locator.click("登陆", "登陆按钮");
        //等待并校验现在的网页的url不是是登陆页面的url
        Assert.assertTrue(locator.waitNotUrl(dataMap.get("登陆页URL")), "没有跳转到新页面，登陆失败");


    }

}